package com.ihelp.rest.mis.platform.service;

import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFPatriarch;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.util.CellRangeAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ihelp.rest.base.po.Page;
import com.ihelp.rest.mis.platform.dao.AbnormaltimeDao;
import com.ihelp.rest.mis.platform.dao.OnlinetimeDao;
import com.ihelp.rest.mis.platform.dao.UserRecordDao;
import com.ihelp.rest.mis.pojo.Abnormaltime;
import com.ihelp.rest.mis.pojo.UserRecord;
import com.ihelp.rest.mis.pojo.Users;
import com.ihelp.rest.mis.users.dao.UsersDao;
import com.ihelp.rest.mis.vo.UserRecordVO;
import com.ihelp.rest.utils.ExcelUtils;
import com.ihelp.rest.utils.MailUtil;
import com.ihelp.rest.utils.JsonCommon;
import com.ihelp.rest.utils.ReadExcelUtil;

@Service
public class UserRecordService {
	
	@Autowired
	private UserRecordDao urDao;
	
	@Autowired
	private AbnormaltimeDao abtDao;
	
	@Autowired
	private UsersDao usersDao;
	
	@Autowired
	private OnlinetimeDao onlinetimeDao;
	
	public JSONObject getRecordList(int page,int rows,String computername,String qtime){
		return JsonCommon.getGridJson(this.urDao.getAllRecordList(page,rows,computername,qtime));
	}
	
	public UserRecord getUserRecordById(String id){
		return this.urDao.get(id);
	}
	
	public String saveRecord(UserRecord ur){
		Map<String, Object> result = new HashMap<String, Object>(); 
		if(StringUtils.isBlank(ur.getId())){
			ur.setId(null);
			ur.setAddtime((new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date()));
		}
		try{
			this.urDao.saveOrUpdate(ur);
			result.put("success", "true");
			result.put("data", "上网记录保存成功");
		}catch(Exception e){
			result.put("success", "false");
			result.put("data", "上网记录保存失败"+e.getMessage());
		}
		return JSONObject.fromObject(result).toString() ;
	}
	
	public String saveRecords(FileInputStream fis){
		Map<String, Object> result = new HashMap<String, Object>(); 
		result.put("success", false);
		result.put("data", "");
		
		ReadExcelUtil readExcel = new ReadExcelUtil(fis); 
		try {
			readExcel.open();
		} catch (IOException e) {
			e.printStackTrace();
			result.put("data", e.getMessage());
		}
		readExcel.setSheetNum(0);
		int count = readExcel.getRowCount();
		String c_date = (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")).format(new Date());
		try{
		List<UserRecord> ur_list = new ArrayList<UserRecord>() ;
			for (int i = 2; i <= count; i++) {
				String[] rows = readExcel.readExcelLine(i);
				UserRecord ur = new UserRecord();
				ur.setAddtime(c_date);
				//for (int j = 1; j < rows.length; j++) {
				//	System.out.print(rows[j] + " ");
				ur.setBrowsetime(rows[1]);
				ur.setComputername(rows[2]);
				ur.setComputergroup(rows[3]);
				ur.setControluser(rows[4]);
				ur.setUsergroup(rows[5]);
				ur.setDomain(rows[6]);
				ur.setTitle(rows[7]);
				ur.setBrowser(rows[8]);
				ur.setUrl(rows[9]);
				ur_list.add(ur);
				//} 
			}
			this.urDao.dosaveUserRecord(ur_list);
			result.put("success", true);
			result.put("data", "导入成功");
		}catch(Exception e){
			result.put("data", e.getMessage());
		}
		return JSONObject.fromObject(result).toString();
	}
	
	public JSONObject  getYCSWByUsercode(int page, int rows,String usercode,String begin,String end){
		Page<UserRecordVO> datalist = new Page<UserRecordVO>();
		List<Abnormaltime> queryPara = this.abtDao.getByUserCode(usercode,"1");
		if(queryPara.size()<1){
			queryPara = this.abtDao.getByUserCode("","0");
		}
		if(queryPara.size()<1){
			return null;
		}
		datalist.setCurrentPage(page);
		datalist.setPageSize(rows);
		return JsonCommon.getGridJson(this.urDao.getYCSW(datalist,queryPara,usercode,begin,end));
	} 
	
	
	public List<Map<String,Object>>  getYCSWByUsercode(String usercode,String begin,String end){
		List<Abnormaltime> queryPara = this.abtDao.getByUserCode(usercode,"1");
		if(queryPara.size()<1){
			queryPara = this.abtDao.getByUserCode("","0");
		}
		if(queryPara.size()<1){
			return null;
		} 
		return this.urDao.getYCSW(queryPara,usercode,begin,end);
	}
	
	
	public  List<Map<String, Object>> getFxbByUsercode(String usercode,String begin,String end){
		List<Map<String, Object>> fxb= this.urDao.queryFxbByUsercode(usercode,begin,end);
		List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();
		double alltime = 0.0;
		for(int i=0;i<fxb.size();i++){
			Map<String, Object> m = fxb.get(i);
			alltime += Double.valueOf(m.get("sc").toString()).doubleValue(); 
		}
		String parten = "#.##";
		DecimalFormat decimal = new DecimalFormat(parten);
		for(int i=0;i<fxb.size();i++){
			Map<String, Object> m = fxb.get(i);
			String str= decimal.format(Double.valueOf(m.get("sc").toString())*100/alltime);
			m.put("BL", str+"%");
			result.add(m);
		}
		Map<String, Object> foot = new HashMap<String, Object>();
		foot.put("TITLENAME", "合计");
		foot.put("SC", decimal.format(alltime));
		foot.put("BL", "100"+"%");
		foot.put("FX", " ");
		result.add(foot);
		return result;
	}
	
	public String exportRecord(HttpServletRequest request, HttpServletResponse response,String userCode, List<Map<String,Object>>  datalist,List<Map<String, Object>> fxb,String begin,String end) {
		Map<String ,Object >  result = new HashMap<String, Object>();
		// 载入Excel模板
		HSSFWorkbook workbook;
		//JSONObject fxblist = JSONObject.fromObject(fxb);
		Users user = this.usersDao.queryUsersByCode(userCode);
		int age = this.usersDao.getYHage(user.getBirthday());
		try {
			
			ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream(); 
			BufferedImage bufferImg =null; 
			String template = request.getSession().getServletContext().getRealPath("/template/swfx.jpg");
			bufferImg = ImageIO.read(new File(template)); 
			ImageIO.write(bufferImg,"jpg",byteArrayOut); 
			
			workbook = new HSSFWorkbook();
			HSSFSheet sheet = workbook.createSheet("月报表");
			HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
			HSSFClientAnchor anchor = new HSSFClientAnchor(0,0,1023,255,(short) 0,0,(short)2,1); 
			patriarch.createPicture(anchor , workbook.addPicture(byteArrayOut.toByteArray(),HSSFWorkbook.PICTURE_TYPE_JPEG)); 

			
			HSSFFont font = workbook.createFont();
			font.setColor(HSSFColor.RED.index);   
		    //cellStyle.setFont(font);    
		    //curCell.setCellStyle(cellStyle);
			
			int rowNum = 1; 
			sheet.setColumnWidth(1, 5000); 
			sheet.setColumnWidth(2, 7000); 
			sheet.setColumnWidth(3, 5000); 
			sheet.setColumnWidth(4, 14000); 
			HSSFRow titleRow = sheet.createRow(rowNum);
	        titleRow.setHeightInPoints(25);
			sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
			//HSSFCell titleCell = titleRow.createCell(1);
	       // titleCell.setCellValue("月报表");
	        HSSFCellStyle titleStyle = workbook.createCellStyle();			//创建大标题样式
	        titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置水平居中显示
	        titleStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);	//设置垂直剧中显示
	        HSSFFont titleFont = workbook.createFont();						//创建样式字体
	        titleFont.setFontHeightInPoints((short)20);						//设置字体大小(12)
	        titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);				//设置字体粗细(加粗)
	        titleStyle.setFont(titleFont);									//应用样式字体到大标题样式
	        titleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	        titleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	        titleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
	        titleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
	        //titleCell.setCellStyle(titleStyle);								//设置大标题样式到单元格
	        
	        HSSFCellStyle redStyle = workbook.createCellStyle();
	        redStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
	        redStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
	        redStyle.setFont(font);
	        
	        
	        HSSFCellStyle title2Style = workbook.createCellStyle();			//创建大标题样式
	        title2Style.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置水平居中显示
	        title2Style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);	//设置垂直剧中显示
	        HSSFFont title2Font = workbook.createFont();						//创建样式字体
	        title2Font.setFontHeightInPoints((short)12);						//设置字体大小(12)
	        title2Font.setFontName("黑体");
	        //title2Font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);				//设置字体粗细(加粗)
	        title2Style.setFont(title2Font);									//应用样式字体到大标题样式
	        title2Style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	        title2Style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	        title2Style.setBorderRight(HSSFCellStyle.BORDER_THIN);
	        title2Style.setBorderTop(HSSFCellStyle.BORDER_THIN);
	        
	        
	        rowNum+=1;
	       
	        HSSFCellStyle cellStyle=workbook.createCellStyle();   
	        cellStyle.setWrapText(true);   
	        cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	        cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	        cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
	        cellStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
	        //yhCell.setCellValue();
	        

	        HSSFCellStyle subTitleStyle = workbook.createCellStyle();		//创建列标题样式
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        HSSFFont subTitleFont = workbook.createFont();					//创建样式字体
	        subTitleFont.setFontHeightInPoints((short)10);					//设置字体大小(10)
	        subTitleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);			//设置字体粗细(加粗)
	        subTitleStyle.setFont(subTitleFont);							//应用样式字体到大标题样
	        subTitleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
	        subTitleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
	        subTitleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
	        subTitleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
	        
	        HSSFRow fxrow = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell fxCell = fxrow.createCell(0);
	        fxCell.setCellValue("孩子上网兴趣月分析报告");
	        fxCell.setCellStyle(titleStyle);
			rowNum+=1;
			
			HSSFRow nyrow = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell nyCell = nyrow.createCell(0);
	        nyCell.setCellValue(begin.substring(0,4)+"年"+begin.substring(5,7)+"月");
	        //nyCell.setCellStyle(titleStyle);
	        nyCell.setCellStyle(redStyle);
			rowNum+=1;
			
			HSSFRow row = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell yhCell = row.createCell(0);
	        StringBuilder zj=  new StringBuilder();  
	        row.setHeight((short) 1000);
	        zj.append("  尊敬的"+user.getName()+"家长：您好！您\"手机号码为："+user.getMobile()+"，用户号为： "+userCode+"\"的"+begin.substring(0,7)+"月份《孩子上网兴趣月分析报告》已产生。报告分析时段为："+begin+"~"+end+"，您的孩子在家上网累计时长为");
	        yhCell.setCellStyle(cellStyle);
	        rowNum+=1;
		    
	        HSSFRow fxbtitle = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell fxbCell = fxbtitle.createCell(0);
	        fxbCell.setCellValue("孩子上网兴趣爱好分析表");
	        fxbCell.setCellStyle(title2Style);
			rowNum+=1;
			HSSFRow fxtrow = sheet.createRow(rowNum);
			
			HSSFCell fx_t0 = fxtrow.createCell(0);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        fx_t0.setCellStyle(subTitleStyle);
	        fx_t0.setCellValue(new HSSFRichTextString("序号"));
	        
			HSSFCell fx_t1 = fxtrow.createCell(1);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        fx_t1.setCellStyle(subTitleStyle);
	        fx_t1.setCellValue(new HSSFRichTextString("网站分类"));
	        HSSFCell fx_t2 = fxtrow.createCell(2);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        fx_t2.setCellStyle(subTitleStyle);
	        fx_t2.setCellValue(new HSSFRichTextString("累计时间（小时）"));
	        HSSFCell fx_t3 = fxtrow.createCell(3);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        fx_t3.setCellStyle(subTitleStyle);
	        fx_t3.setCellValue(new HSSFRichTextString("占总上网时间比重"));
	        HSSFCell fx_t4 = fxtrow.createCell(4);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        fx_t4.setCellStyle(subTitleStyle);
	        fx_t4.setCellValue(new HSSFRichTextString("相关分析及建议"));

	        rowNum+=1; 
	        double sumSC = 0.0 ;
			for(int i=0;i<fxb.size();i++){
				 //JSONObject jsonItem = fxb;
				 Map m = fxb.get(i);
				 HSSFRow data_row =  sheet.createRow(rowNum);
				 HSSFCell data_0 = data_row.createCell(0);
				 data_0.setCellStyle(cellStyle);
				 data_0.setCellValue(i+1);
				 HSSFCell data_1 = data_row.createCell(1);
				 data_1.setCellStyle(cellStyle);
				 //data_1.setCellValue(new HSSFRichTextString(jsonItem.getString("TITLENAME")));
				 data_1.setCellValue(new HSSFRichTextString((String) m.get("TITLENAME")));
				 HSSFCell data_2 = data_row.createCell(2);
				 data_2.setCellStyle(cellStyle);
//				 data_2.setCellValue(new HSSFRichTextString(jsonItem.getString("SC")));
				 data_2.setCellValue(new HSSFRichTextString(String.valueOf(m.get("SC"))));
				 HSSFCell data_3 = data_row.createCell(3);
				 data_3.setCellStyle(cellStyle);
//				 data_3.setCellValue(new HSSFRichTextString(jsonItem.getString("BL")));
				 data_3.setCellValue(new HSSFRichTextString((String) m.get("BL")));
				 HSSFCell data_4 = data_row.createCell(4);
				 data_4.setCellStyle(cellStyle);
//				 data_4.setCellValue(new HSSFRichTextString(jsonItem.getString("FX")));
				 data_4.setCellValue(new HSSFRichTextString((String) m.get("FX")));
				 rowNum+=1;
				 if(!((String) m.get("TITLENAME")).equals("合计")){
					 sumSC+=Double.valueOf(String.valueOf(m.get("SC")));
				 }
			}

			rowNum+=1; 
			HSSFRow ycrow = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell ycCell = ycrow.createCell(0);
	        ycCell.setCellValue("温馨提示信息");
	        titleStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);//设置填充模式
	        titleStyle.setFillForegroundColor(HSSFColor.WHITE.index);
	        ycCell.setCellStyle(title2Style);	
	        
	        rowNum+=1;
	        HSSFRow trow = sheet.createRow(rowNum);
	        HSSFCell t_0 = trow.createCell(0);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        t_0.setCellStyle(subTitleStyle);
	        t_0.setCellValue(new HSSFRichTextString("序号"));
	        
	        HSSFCell t_1 = trow.createCell(1);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        t_1.setCellStyle(subTitleStyle);
	        t_1.setCellValue(new HSSFRichTextString("异常上网开始时间"));
	        
	        HSSFCell t_2 = trow.createCell(2);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        t_2.setCellStyle(subTitleStyle);
	        t_2.setCellValue(new HSSFRichTextString("网页标题"));
	        
	        HSSFCell t_3 = trow.createCell(3);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        t_3.setCellStyle(subTitleStyle);
	        t_3.setCellValue(new HSSFRichTextString("类型"));
	        
	        HSSFCell t_4 = trow.createCell(4);
	        subTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);			//设置居中显示
	        t_4.setCellStyle(subTitleStyle);
	        t_4.setCellValue(new HSSFRichTextString("网页地址"));

			int i=1;
	        rowNum+=1;
			for(Map<String, Object> map : datalist){
				HSSFRow data_row =  sheet.createRow(rowNum);
				HSSFCell data_0 = data_row.createCell(0);
				data_0.setCellStyle(cellStyle);
				data_0.setCellValue(i);
				HSSFCell data_1 = data_row.createCell(1);
				data_1.setCellStyle(cellStyle);
				data_1.setCellValue(new HSSFRichTextString(String.valueOf(map.get("BROWSETIME"))));
				HSSFCell data_2 = data_row.createCell(2);
				data_2.setCellStyle(cellStyle);
				data_2.setCellValue(new HSSFRichTextString(String.valueOf(map.get("TITLE"))));
				HSSFCell data_3 = data_row.createCell(3);
				data_3.setCellStyle(cellStyle);
				data_3.setCellValue(new HSSFRichTextString(String.valueOf(map.get("TYPENAME"))));
				HSSFCell data_4 = data_row.createCell(4);
				data_4.setCellStyle(cellStyle);
				data_4.setCellValue(new HSSFRichTextString(String.valueOf(map.get("URL"))));
				rowNum+=1; 
				i++;
			}
			
			
			int days = this.usersDao.getCountDay(begin, end);
			double pjz= days==0?0:sumSC/days;
			String suggetstime = "0";
			try{
				suggetstime = String.valueOf(this.onlinetimeDao.getSuggestTime(age));
			}catch(Exception e){
				suggetstime = "(未匹配到)";
			}
			zj.append(String.format("%.2f", sumSC)+"小时；本时间段平均每天上网时间"+String.format("%.2f", sumSC)+"/"+days+"="+String.format("%.2f", pjz)+"(小时)；根据您孩子的年龄，我们建议他平均上网时间应< "+suggetstime+"小时，以免影响孩子的健康成长及学习成绩。" +
					"以下为您孩子"+begin.substring(0,7)+"月份《孩子上网兴趣爱好分析表》及《温馨提示信息》。");
			yhCell.setCellValue(zj.toString());
			
			rowNum+=1; 
			HSSFRow lastrow = sheet.createRow(rowNum);
	        sheet.addMergedRegion(new CellRangeAddress(rowNum, rowNum, 0, 4));
	        HSSFCell lastCell = lastrow.createCell(0);
	        lastCell.setCellValue("*以上报告由i-ECC系统自动生成。");
	        rowNum+=1; 
			HSSFRow last1row = sheet.createRow(rowNum);
	        HSSFCell lastname = last1row.createCell(4);
	        lastname.setCellValue("青少年上网教育辅导中心");
	        rowNum+=1; 
			HSSFRow lastdate = sheet.createRow(rowNum);
	        HSSFCell dataCell = lastdate.createCell(4);
	        SimpleDateFormat dateformat2=new SimpleDateFormat("yyyy年MM月dd日 ");   
	        String a2=dateformat2.format(new Date());
	        dataCell.setCellValue(a2);
	        String fileFullPath = request.getSession().getServletContext().getRealPath("/temp")+File.separator+userCode+"_"+begin+"-"+end+".xls";
	        FileOutputStream fOut = new FileOutputStream(fileFullPath);
	        workbook.write(fOut); 
	        fOut.flush();
	        fOut.close();
	        if(StringUtils.isBlank(user.getEmail())){
	        	result.put("success", false);
				result.put("data", "邮件发送失败，请先维护此用户的邮箱！");
	        }else{
	        	MailUtil.sendMail("529032769","qianfl123",user.getEmail(),user.getName(), fileFullPath,"尊敬的用户：您的异常上网记录已发出，详情请查看附件！");
	        	result.put("success", true);
				result.put("data", "邮件已发送！");
	        }
	        //ExcelUtils.output(response, "d:\\"+userCode, workbook);
		}catch(Exception e){
			e.printStackTrace();
			result.put("success", false);
			result.put("data", "邮件发送失败:"+e.getMessage());
		}
		return JSONObject.fromObject(result).toString();
	}
	
	public String delRecord(String id){
		Map<String ,Object >  result = new HashMap<String, Object>();
		try{
			this.urDao.delete(id);
			result.put("success", "true");
			result.put("data", "上网记录删除成功");
		}catch(Exception e){
			result.put("success", "false");
			result.put("data", "上网记录删除失败"+e.getMessage());
		}
		return JSONObject.fromObject(result).toString() ;
	}
}
